package com.gxa.service.baoBiaoService.impl;

import com.gxa.common.R;
import com.gxa.mapper.baobiaomapper.CaiGouBaoBiaoMapper;
import com.gxa.service.baoBiaoService.CaiGouBaoBiaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Service
public class CaiGouBaoBiaoServiceImpl  implements CaiGouBaoBiaoService {

    @Autowired
    private CaiGouBaoBiaoMapper caiGouBaoBiaoMapper;

    SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );

    @Override
    public R selectCaiGouMingXi(String startTime, String endTime, String gongYingShangId,
                                String shangPinId, String cangKuId) throws ParseException {


        R r=new R();

        List list = new ArrayList();
        r.setCode(200);
        r.setMsg("没有查到数据！");

        if (startTime==null||endTime==null){
            r.setCode(500);
            r.setMsg("请先输入查询时间！");
        }else {
            list=caiGouBaoBiaoMapper.selectCaiGouMingXi(startTime, endTime ,  gongYingShangId, shangPinId, cangKuId);
            if (list.size()!=0){
                r.setCode(200);
                r.setMsg("采购明细表查询成功！");
                r.setData(list);
            }
        }
        return r;
    }
}
